package com.service;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.domain.Klant;
import com.interfaces.IKlantDAO;

@Repository("klantDAO")
public class KlantDAO extends HibernateDAO<Klant, Integer> implements IKlantDAO{

	@Override
	public int getHoogsteKlantNr() {
		 Query query = currentSession().createQuery(
	                "select MAX(k.id) from klant k");
		return (Integer)query.uniqueResult();	
	}
	
	@Override
	public Klant vindByNaam(String naam) {
		 Query query = currentSession().createQuery(
	                "from klant k where k.naam =:naam");
		 query.setString("naam", naam);
		return (Klant)query.uniqueResult();	
	}
}
